{- CPU.inc.orc -- Orc program CPU.inc
 - 
 - $Id$
 - 
 - Created by akattepu on Sep 5, 2012 4:26:28 PM
 -}

def bestQoS(comparer, publisher) = head(sortBy(comparer, publisher))
val curTime = Rclock()

type Percentage = Number
def Percentage() = signal
def CPUutilizationValue(sitex) = (sitex,curTime.time()) >(sitex,d)> (sitex,curTime.time()-d) >(_,delta)> (100 /(1+ delta)) 
 
-- Types and Definitions for Response Time
type CPUutilization = Number
def class CPUutilization(unit) =
  def QoS(String) :: Number
  def QoS(sitex) = signal >> CPUutilizationValue(sitex) 
  
  def QoSOplus(Number,Number) :: Number
  def QoSOplus(rt1,rt2) = rt1+rt2
  
  def QoSCompare(Number,Number) :: Number
  def QoSCompare(rt1,rt2) = rt1 >= rt2
  
  def QoSCompete(Number,Number) :: Number
  def QoSCompete(rt1,rt2) = bestQoS(QoSCompare,[rt1,rt2])
  
  def QoSVee(Number,Number) :: Number
  def QoSVee(rt1,rt2) = min(rt1,rt2)
  stop